
#import "NetManager.h"

#define wlccontent @"http://appid.qq-app.com/frontApi/getAboutUs?appid=appid"

@implementation NetManager

+(NetManager*)shareInstance {
    static NetManager *_instance = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[NetManager alloc] init];
    });
    return _instance;
}

- (void)getInfo:(void(^)(id responseObject))resultHandle {
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer = [AFHTTPResponseSerializer serializer];

    
    [manager GET:wlccontent parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSError *error = nil;
        id jsonObject = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error];
        if (jsonObject != nil && error == nil) {
            if (resultHandle) {
                resultHandle(jsonObject);
            }
            
        } else {
            if (resultHandle) {
                resultHandle(nil);
            }
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"manager error = %@", error);
        if (resultHandle) {
            resultHandle(nil);
        }
    }];
}

@end
